package P4414;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a= sc.nextInt(),b= sc.nextInt(),c = sc.nextInt();
        if (a>b){
            a ^= b;
            b ^= a;
            a ^= b;
        }
        if (a>c){
            a ^= c;
            c ^= a;
            a ^= c;
        }
        if (b>c){
            b ^= c;
            c ^= b;
            b ^= c;
        }
        String ABC = sc.next();
        for (int i=0;i<3;++i){
            if (ABC.charAt(i) =='A') System.out.print(a +" ");
            else if (ABC.charAt(i) =='B') System.out.print(b +" ");
            else if (ABC.charAt(i) =='C') System.out.print(c +" ");
        }


    }

}
